<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
        <script>
            $(function(){
                $("#username").blur(function () {
                    $.getJSON("${pageContext.request.contextPath}/user/validateUsername",
                              {"username":$(this).val()},
                              function(ajaxResult){
                                if("success"==ajaxResult.name){
                                    $("#usernameMessage").css("color","green");
                                }else{
                                    $("#usernameMessage").css("color","red");
                                }
                                $("#usernameMessage").text(ajaxResult.data);
                              })
                });
            });
        </script>
    </head>
    <body>
        <h1>用户注册</h1>
        <hr/>
        <form action="${pageContext.request.contextPath}/user/regist" method="post">
            用户名：<input id="username" type="text" name="username"/>
                   <span id="usernameMessage"></span><br/>
            密码：<input type="password" name="password"/><br/>
            性别：<input type="radio" name="sex" value="1"/>男
                 <input type="radio" name="sex" value="0"/>女<br/>
            学历：<select name="edu">
                    <option value="-1">---请选择---</option>
                    <option value="1">高中</option>
                    <option value="2">专科</option>
                    <option value="3">本科</option>
                 </select><br/>
            兴趣爱好：<input type="checkbox" name="hobbies" value="1"/>吃
                    <input type="checkbox" name="hobbies" value="1"/>玩
                    <input type="checkbox" name="hobbies" value="1"/>睡<br/>
            简介：<textarea rows="5" cols="20" name="description"></textarea><br/>
            <input type="submit" value="注册">
        </form>
        ${e.message}
    </body>
</html>
